#!/usr/bin/env python
# -*- coding: utf-8 -*-

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from autoPilot import Pilot
from PIL import Image
import io
import os
import time
import ddddocr







# 配置 Chrome 浏览器选项
chrome_options = Options()
chrome_options.add_argument("--headless") # 启用无头模式
chrome_options.add_argument("--disable-gpu") # 禁用 GPU 加速（可选）
chrome_options.add_argument("--window-size=1920,1080") # 设置窗口大小（可选）
# 设置 Chrome 驱动路径
service = Service('C:/Users/Administrator/bin/chromedriver.exe')

# 启动浏览器
driver = webdriver.Chrome(options=chrome_options)


# 创建保存验证码图片的文件夹
output_dir = 'captchas'
os.makedirs(output_dir, exist_ok=True)

# 定义采集验证码图片的数量
num_captchas = 5

auto_pilot = Pilot(headless=True)
auto_pilot.train(num_captchas, output_dir)

# 关闭浏览器
auto_pilot.quit()
